using System;
namespace MSR.CVE.BackMaker
{
	public class SampleHTMLWriterConstants
	{
		public static string Body(string showDefaultLayerName, string checkboxesHTML, string crunchedFilename)
		{
			return string.Concat(new string[]
			{
				"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\r\n<head>\r\n\r\n        <title>MapCruncher Mashup Sample Web Page</title>\r\n",
				string.Format("\r\n        <script src=\"{0}\" type=\"text/javascript\"></script>\r\n        <script src=\"{1}CrunchControl.js\" type=\"text/javascript\"></script>\r\n        <link href=\"{1}LegendStyle.css\" rel=\"stylesheet\" type=\"text/css\">\r\n", BuildConfig.theConfig.mapControl, BuildConfig.theConfig.hostHome),
				"\r\n        <script type=\"text/javascript\">\r\n\r\n        var div = null;\r\n        var map = null;\r\n        var crunchedLayerManager = null;\r\n\r\n        function ToggleLayer(name, active)\r\n        {\r\n                if (active == true)\r\n                {\r\n                        crunchedLayerManager.layerList.find(name).Activate(map);\r\n                }\r\n                else\r\n                {\r\n                        crunchedLayerManager.layerList.find(name).Deactivate(map);\r\n                }\r\n        }\r\n\r\n        function searchboxactivate()\r\n        {\r\n            txt = document.getElementById('searchbox').value;\r\n            map.Find(txt, \"\");\r\n        }        \r\n\r\n        function GetSize()\r\n        {\r\n                var myWidth = 0, myHeight = 0;\r\n\r\n                if( typeof( window.innerWidth ) == 'number' ) {\r\n                    //Non-IE\r\n                    myWidth = window.innerWidth;\r\n                    myHeight = window.innerHeight;\r\n                } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {\r\n                    //IE 6+ in 'standards compliant mode'\r\n                    myWidth = document.documentElement.clientWidth;\r\n                    myHeight = document.documentElement.clientHeight;\r\n                } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {\r\n                    //IE 4 compatible\r\n                    myWidth = document.body.clientWidth;\r\n                    myHeight = document.body.clientHeight;\r\n                }\r\n\r\n                if (myWidth > 0)\r\n                {\r\n                        var result = new Array();\r\n                        result[0] = myWidth;\r\n                        result[1] = myHeight;\r\n                        return result;\r\n                }\r\n                else\r\n                {\r\n                        return null;\r\n                }\r\n        }\r\n\r\n        function SetMapSize()\r\n        {\r\n                var browserSize = GetSize();\r\n\r\n                var div = document.getElementById(\"Map\");\r\n\r\n                if (browserSize != null)\r\n                {\r\n                        div.style.width = (browserSize[0] - 25) + \"px\";\r\n                        div.style.height = (browserSize[1] - 25) + \"px\";\r\n\r\n                }\r\n                else\r\n                {\r\n                        div.style.width = \"800px\";\r\n                        div.style.height = \"600px\";\r\n                }\r\n                div.style.overflow = \"hidden\";\r\n                div.style.position = \"relative\";\r\n\r\n\t\t\t\tif (crunchedLayerManager!=null)\r\n\t\t\t\t{\r\n\t\t\t\t\tcrunchedLayerManager.controlManager.UpdateControlLayout();\r\n\t\t\t\t}\r\n        }\r\n\r\n        function MapModeChanged(e)\r\n        {\r\n                if (map.GetMapMode() == Msn.VE.MapActionMode.Mode3D &&\r\n                    window.location.protocol == \"file:\")\r\n                {\r\n                        alert(\"MapCruncher tiles will only display in 3D mode \" +\r\n                        \"if your map is hosted on a web server (using http://).\\n\" +\r\n                        \"Currently, your tiles are coming from a local machine (file://) \" +\r\n                        \"so only 2D mode is available.\");\r\n                }\r\n        }\r\n\r\n        function LoadPage()\r\n        {\r\n                SetMapSize();\r\n                window.onresize = SetMapSize;\r\n\r\n                map = new VEMap('Map');\r\n                map.LoadMap();\r\n                map.AttachEvent(\"oninitmode\", MapModeChanged);\r\n                map.SetMapStyle('h');\r\n\r\n\t\t\t\tcrunchedLayerManager = new VE.MapCruncher.CrunchedLayerManager(map);\r\n\t\t\t\tcrunchedLayerManager.controlManager.AddControl(\r\n\t\t\t\t\t\t\"aboutDiv\", \"About this sample page\",\r\n\t\t\t\t\t\tnew VE.MapCruncher.LayoutSpec(\"right\", 10, \"top\", 12),\r\n\t\t\t\t\t\ttrue, false);\r\n                crunchedLayerManager.ImportLayersFromAnchorHRef(\"CrunchedLayers\");\r\n                var permalinkProvided = crunchedLayerManager.ApplyPermalink(document.layerCheckboxForm);\r\n\r\n                if (!permalinkProvided) {\r\n          var layer = crunchedLayerManager.layerList.find('",
				showDefaultLayerName,
				"');\r\n                    layer.Activate(map);\r\n                    layer.SetDefaultView(map);\r\n                }\r\n        }\r\n\r\n        </script>\r\n\r\n</head>\r\n<body onload=\"LoadPage()\">\r\n\r\n<div id=\"Map\"></div>\r\n\r\n<div style=\"display:none\">\r\n\t<a id=\"CrunchedLayers\" href=\"",
				crunchedFilename,
				"\">CrunchedLayers</a>\r\n</div>\r\n\r\n<div id=\"aboutDiv\" style=\"background:white; width:400px; border: 2px solid #0000c0\">\r\n<div style=\"padding:10px\">\r\n<p> Welcome to your new Mashup -- powered by <a href=\"",
				BuildConfig.theConfig.mapCruncherHomeSite,
				"\">MapCruncher</a> Beta for\r\nMicrosoft <a href=\"http://local.live.com/\">Virtual Earth</a>!\r\nThis HTML file is a sample.  It demonstrates how to build a real web page that uses\r\nthe map layer you just rendered.\r\nTo publish this mashup, just move the whole folder to your web server.\r\n\r\n<p>\r\n\r\n\r\n<form action=\"javascript:searchboxactivate()\">\r\n\t<b>Search the map for businesses (e.g., \"pizza\"):</b>\r\n\t<input id=\"searchbox\" type=\"text\" name=\"searchbox\" size=\"20\">\r\n\t<input id=\"sbutton\" type=\"button\" value=\"Go!\" onclick=\"javascript:searchboxactivate()\">\r\n</form>\r\n\r\n        <form action=\"None\" name=\"layerCheckboxForm\">\r\n<b>Select Mashup Layers:</b>\r\n",
				checkboxesHTML,
				"\r\n</form>\r\n</div>\r\n</div>\r\n\r\n</body>\r\n</html>\r\n"
			});
		}
	}
}
